package com.blog.user.service.impl;

import com.blog.user.dao.AuthMenuDao;
import com.blog.user.pojo.*;
import com.blog.user.service.AuthMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.blog.util.IdWorker;

import java.util.Date;
import java.util.List;

/**
 * 这里分页使用的是pagehelper
 */
@Service
@Transactional(readOnly = false)
public class AuthMenuServiceImpl implements AuthMenuService {

    @Autowired
    private IdWorker idWorker;

    @Autowired
    private AuthMenuDao authMenuDao;


    @Override
    public List<AuthMenu> findAll(int page, int size, String query) {
        return null;
    }

    @Override
    public AuthMenu findById(String id) {
        return authMenuDao.selectById(id);
    }

    @Override
    public void insert(AuthMenu authMenu) {
        String id = idWorker.nextId()+"";
        authMenu.setId(id);
        authMenu.setCreateTime(new Date());
        authMenuDao.insert(authMenu);
    }

    @Override
    public void update(AuthMenu authMenu) {
        authMenu.setUpdateTime(new Date());
        authMenuDao.updateById(authMenu);
    }

    @Override
    public void deleteById(String id) {
        authMenuDao.deleteById(id);
    }
}